/**
 * Created by boot on 8/12/15.
 * Any question mail to dozray@163.com
 */
function accAdd(arg0,arg1){
    var n1,n2,m;
    try{
        n1=arg0.toString().split(".")[1].length;
    }catch(e){
        n1 =0;
    }
    try{
        n = arg1.toString().split(".")[1].length;
    }
    catch(e)
    {
        n2 =0;
    }
    m = Math.pow(10,Math.max(n1,n2));
    return (arg0*m + arg1*m)/m;
}

function accSub(arg0,arg1){
    return accAdd(arg0,-arg1);
}

/**
 * Multiply
 */
function accMul(arg0,arg1){
    var s1,s2,m=0;
    s1=arg0.toString();
    s2=arg1.toString();
    try{
        m+=s1.split(".")[1].length;
    }catch(e){}

    try{
        m+=s2.split(".")[1].length;
    }catch(e){}

    return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
}

/**
 * Division
 */
function accDiv(arg0,arg1){

    var t1= 0,t2= 0,n1,n2;
    var s1=arg0.toString();
    var s2=arg1.toString();

    try{
        t1=s1.split(".")[1].length;
    }catch(e){}
    try{
        t2=s2.split(".")[1].length;
    }catch(e){}

    if(t1==0 && t2==0)
        return arg0/arg1;

    with(Math){
        n1=Number(s1.replace(".",""));
        n2=Number(s2.replace(".",""));
        return(n1/n2)*pow(10,t2-t1);
    }
}

function isInt(arg){
    return /^-?\\d+$/.test(arg);
}


Number.prototype.isInt=function(arg){
    return isInt(arg);
}

Number.prototype.add=function(arg){
    return accAdd(this,arg);
}
Number.prototype.sub=function(arg){
    return accSub(this,arg);
}
Number.prototype.mul=function(arg){
    return accMul(this,arg);
}
Number.prototype.div=function(arg){
    return accDiv(this,arg);
}





